/**
 * 信科业务相关的工具类
 */
//内容类型对应关系
export const contentTypes = [
  {key: 1, name: '文章'},
  // {key: 2, name: '视频'},
  // {key: 3, name: '音频'},
  // {key: 4, name: 'H5'},
];

export function findContentType(contentType) {
  if (contentType) {
    return contentTypes.find(item => item.key == contentType)
  }
}

//选题类型对应关系
export const topicTypes = [
  {key: 1, name: '传统媒体'},
  {key: 2, name: '新媒体'},
  {key: 3, name: '传统媒体+新媒体（全媒体）'}
];

export function findTopicTypeName(topicType) {
  if (topicType) {
    const match = topicTypes.find(item => item.key == topicType)
    if (match) {
      return match.name;
    }
  }
}

//选题审核结果
export const topicCheckTypes = [
  {key: 0, name: '待审核'},
  {key: 1, name: '审核通过'},
  {key: 2, name: '审核未通过'}
];

export function findTopicCheckResultName(checkResult) {
  if (typeof checkResult !== 'undefined' && checkResult != null) {
    const match = topicCheckTypes.find(item => item.key == checkResult)
    if (match) {
      return match.name;
    }
  }
}

export function isImg(item) {
  if (!item.fileSuffix || !item.fileUrl) {
    return false;
  }
  const partern = /jp[e]?g|png|gif|webp|svg|psd|bmp/i;
  return item.fileType == 2 && partern.test(item.fileSuffix);
}

export function isImgFile(suffix){
  if(suffix){
    const partern = /jp[e]?g|png|gif|webp|svg|psd|bmp/gi;
    return partern.test(suffix);
  }
}
//*.avi *.rmvb *.rm *.asf *.divx *.mpg *.mpeg *.mpe *.wmv *.mp4 *.mkv *.vob
export function isVideoFile(suffix){
  if(suffix){
    const partern = /mp4|avi|rmvb|rm|divx|mpe?g|wmv|mkv|vob|m4v/gi;
    return partern.test(suffix);
  }
}

//音频 wav、mp3、mppr、wma和asf
export function isAudioFile(suffix){
  if(suffix){
    const partern = /wav|mp3|mppr|wma|asf/gi;
    return partern.test(suffix);
  }
}